package com.kunteng.ynhxksh.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

/**
 * Created By ShiYun with IntelliJ IDEA on 2018/3/27 14:06
 *
 * @author: ShiYun
 * @Email: 515867726@qq.com
 * @Date: 2018/3/27
 * To change this template use File | Settings | File Templates.
 */
@Component
public class Example {

    Logger logger = LoggerFactory.getLogger(Example.class);


    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**
     * 固定频率：单位ms 示例中代表每10s执行1次
     */
//    @Scheduled(fixedRate = 10 * 1000)
    public void run() {
        logger.info("Every fixed time to excute {}", simpleDateFormat.format(System.currentTimeMillis()));
    }


    /**
     * 表达式执行
     */
//    @Scheduled(cron = "0 0/1 * * * ?")
    public void run1() {
        logger.info("The cron time to excute {}", simpleDateFormat.format(System.currentTimeMillis()));
    }
}
